package cn.yuemouren.collection.set;

import cn.yuemouren.collection.Set;
import cn.yuemouren.linkedlist.LinkedList;

/**
 * @Author: Timi
 * @Description: 链表实现set集合
 * @Date: 2020/6/18 9:27
 */
public class LinkListSet<T> implements Set<T> {

    private LinkedList<T> linkedList;

    public LinkListSet() {
        linkedList = new LinkedList<>();
    }

    @Override
    public int getSize() {
        return linkedList.getSize();
    }

    @Override
    public boolean isEmpty() {
        return linkedList.isEmpty();
    }

    @Override
    public void add(T t) {
        if(!linkedList.contains(t))
            linkedList.addFirst(t);
    }

    @Override
    public void remove(T t) {
        linkedList.removeElement(t);
    }

    @Override
    public boolean comtains(T t) {
        return linkedList.contains(t);
    }
}
